home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 2002 November / CD 1 / APC0211D1.ISO / workshop / prog / files / script.pl < prev   
Encoding:
Perl Script  |  2002-09-24  |  1.1 KB  |  30 lines

  1. #!/usr/bin/perl
  2. # APC Perls of Wisdom code example, November 2002
  3. # by Matthew Overington, APC
  4. # -----------------------------------------------
  5. # The first line of any Perl program points to where perl is installed on the server
  6. # As we are running under Linux in the APC office, ours points to the usr/bin/perl folder
  7.  
  8. if ($ENV{æQUERY_STRINGÆ} =~ /exec/i) {
  9.     &header;            # Calls the header subroutine to send a header back to the browser
  10.     &HelloWorld;            # Calls the HelloWorld subroutine, which prints Hello World.
  11. }
  12.  
  13.                     # This else block is executed if the correct exec string is not passed from the browser
  14.                     # The \n character could confuse a few people; it's the standard perl syntax for a new line
  15. else {                    
  16.     &header;
  17.     print "You got that wrong... Try Again.\n<br>";
  18. }
  19.  
  20.                     # We have chosen to put our subroutines at the end of the main program block.
  21. Sub HelloWorld {
  22.     Print "Hello World\n<br>";
  23.  
  24. Sub header {                # The header subroutine, which is used to alert the browser to the incoming stream
  25.     print "Content-type: text/html\n\n";
  26. }
  27.  
  28.  
  29.